<?php
/**
 * Created by PhpStorm.
 * User: Shroom Ari
 * Date: 11/20/14
 * Time: 11:25 AM
 */
class Mproducttype extends MY_Model{
    public $table = 'product_type';
    public function __construct(){
        parent::__construct();
    }
    function getProductType($perpage,$offset){

        $query = $this->db->get('product_type',$perpage,$offset);
        return $query->result_array();
    }
    function getProductTypeById($id){
        $this->db->select('*');
        $this->db->from('product_type');
        $this->db->where('product_type_id',$id);
        $this->db->limit(1);
        $query = $this->db->get();
        return $query->result_array();
    }
    function countAll(){
        return $this->db->count_all('product_type');
    }
    function delete($id){
        $this->db->where('product_type_id',$id);
        $this->db->delete('product_type');
        if ($this->db->_error_number() == 1451){
            return false;
        }
        return true;
    }
    function updateType($id,$dt){
        $this->db->where('product_type_id',$id);
        if ($this->db->update('product_type',$dt))
            return TRUE;
        else return FALSE;
    }

    function get_product_type(){
        $this->db->select("*");
        $query = $this->db->get("product_type");
        return $query->result_array();
    }
}